package lanqiao;

public class 路径 {
    public static void main(String[] args) {
        int[] arr = new int[2022];
        for (int i = 2; i <arr.length ; i++) {
            arr[i] = Integer.MAX_VALUE;
        }
        for (int i = 1; i <=2020; i++) {
            for (int j = i+1; j <= 2021 && j<=(21+i); j++) {
                    arr[j] = Math.min(arr[j],arr[i]+le(i,j));
            }
        }
        System.out.println(arr[2021]);
    }
    public static int gcd(int a,int b){
        return b!=0 ? gcd(b,a%b) : a;
    }

    public static int le(int a,int b){
        return a*b/gcd(a,b);
    }
}
